<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
</body>
<script>
    var wsServer = 'ws://127.0.0.1:19992';
    var websocket = new WebSocket(wsServer);
    websocket.onopen = function (evt) {
        console.log("connected to server");
        websocket.send(JSON.stringify(data))
    };

    var data = {
        "action": "getState",
        "type": "weChat"
    };

    websocket.onclose = function (evt) {
        console.log("disconnected");
    };

    websocket.onmessage = function (evt) {
        console.log('received data from server: ' + evt.data);
        console.log(typeof evt.data)
        var data = JSON.parse(evt.data);
        if (data['user_info']) {
            console.log('user_info: ')
            console.log(data['user_info']);
        }
        console.log('----------end----------')
    };

    websocket.onerror = function (evt, e) {
        console.log('error: ' + evt.data);
    };
</script>
</html>
